#===================================================================================#
#                                                 __                                #
#                                                /\ \__                             #
#                    _____   _ __   __  __    ___\ \ ,_\                            #
#                   /\ '__`\/\`'__\/\ \/\ \ /' _ `\ \ \/                            #
#                   \ \ \_\ \ \ \/ \ \ \_\ \/\ \/\ \ \ \_    __   __                #
#                    \ \  __/\ \_\  \/`____ \ \_\ \_\ \__\  /\_\ /\_\               #
#                     \ \ \/  \/_/   `/___/> \/_/\/_/\/__/  \/_/ \/_/               #
#                      \ \_\            /\___/                                      #
#                       \/_/            \/__/                                       #
#                                                                                   #
#===================================================================================#
#@copyright: 2008 by Jeremy Bouillanne
#@license: Apache Public Licence
__revision = '$Revision:  $'[11:-2]

import main
from matplotlib import show
import mathtext
import rest
import sys

class configuration(object):
    matplotlib = matplotlib.matplotlib()
    mathtext = mathtext.mathtext()
    #rest = rest.rest()
    
    filename = None
    path = "img"
    output = "html"
    autoopen = True

    def __init__(self, **kwargs):
        for k,v in kwargs.items():
            self.__setattr__(k,v)
            
    def getfilepath(self, filename, filetype):
        from os import mkdir
        from os.path import join, exists
        if exists(self.path) == False : mkdir(self.path)
        return join(config.path, filename+"."+filetype)

__prynter = main.prynter(sys.stdout) 
sys.stdout=__prynter

config = configuration(mathtext = mathtext.__config, matplotlib=matplotlib.__config)

def prynt():
    __prynter.prynt() 
    
def pryntonexit():
    import atexit
    atexit.register(prynt)    